home *** CD-ROM | disk | FTP | other *** search
/ Hacker's Arsenal - The Cutting Edge of Hacking / Hacker's Arsenal - The Cutting Edge of Hacking.iso / texts / misc / auditing.txt < prev    next >
Encoding:
Text File  |  2001-07-11  |  13.4 KB  |  235 lines

  1.  
  2.         An approach to systematic network auditing
  3.        ============================================
  4.  
  5.    Security papers - members.tripod.com/mixtersecurity/papers.html
  6.  
  7. In the past few years, people have learned that a well concepted network
  8. installation done by administrators with average knowledge of security could
  9. still very often be compromised due to the large amount of possibilities
  10. to attack and discovered vulnerabilities an intruder nowadays has at his
  11. disposal. This is the cause why recently security auditing and penetration
  12. testing has become popular for big companies, security-aware individuals and
  13. of course the security industry. Network auditing, or penetration tests can
  14. be seen as a systematic attempt to gain access to a network by discovering
  15. all points of access to it, and then analyzing those points for any known
  16. vulnerabilities, which a real intruder could use to gain further access.
  17. However, many companies are performing this kind of analysis in a manner,
  18. which is really not sufficient and systematic enough to spot all possible
  19. vulnerabilities. So, here is one possible approach, in a nutshell, that
  20. I would take to secure a network systematically.
  21.  
  22. _______________________________________________________________________________
  23.  
  24. 1. Starting off with a secure network
  25.  
  26. The main pre-requirement for having a secure network is to start off with
  27. installations of which you can be sure that no security intrusion has
  28. previously happened. Imagine a big company severely securing their
  29. resources, only to find they have been compromised a year before, and the
  30. attacker has changed the system kernel so he doesn't require any vulnerable
  31. program at all to gain access anymore. There hasn't even to be a permanently
  32. open tcp or udp port; if the intruder is clever, he had reprogrammed the
  33. system to watch for raw data containing secret activation code, and then
  34. give backdoor access for a very short period of time, that cannot be detected
  35. unless one knows the correct code. Take a look at the Q [1] remote shell, if
  36. you need an example.
  37.  
  38. So, first of all, (re-) install your operating systems, making sure that
  39. there is are no binary executables left from old installations. Importing
  40. other kind of data from other systems generally creates no security risk.
  41. If you are open-minded enough to take an advice on what OS to use, then let
  42. me suggest anything except Windows NT. Systems like HPUX/AIX/IRIX are no good,
  43. either, because they are not open source. The problem is that you CANNOT
  44. trust systems that come without their source code to be secure at all. The
  45. vulnerabilities which exist in the software and kernel of commercial non-
  46. open-source systems are not worse than those in other systems, but they EXIST, 
  47. and it is very hard for the security community to identify them, and it takes
  48. alot more time. For an example, SunOS / Solaris was always said to be very
  49. secure, until recently its creators decided to make the source code public
  50. (which was a good idea in long-time measures). Quickly, a huge lot of
  51. vulnerabilities  that couldn't be detected before were found in Solaris, and
  52. some people still consider it to be extraordinary secure... this was the right
  53. step on becoming a secure operating system, but it will surely take a long time
  54. until virtually all vulnerabilities have been spotted.
  55.  
  56. If you want a secure operating system, install a BSD derivate, such as OpenBSD.
  57. You can also use Solaris, or Linux if you have sufficient knowledge of securing
  58. it. The most problematic thing is, that it has become very easy to install even
  59. a complex UNIX system, and that many people only do enough to get it up and
  60. running. You should get a system that is at least one year old, or older, to
  61. make sure that most of the vulnerabilities present in the system have already
  62. been spotted - this is important, the people who always install the newest
  63. version of their systems, one day after they come out, put their security at
  64. risk worse than people who run outdated, but well-patched systems.
  65. Secondly, go to your vendors web site and inform yourself about which
  66. software packages you should update. Regarding security purposes, it is only
  67. important to update packages that are suid root, always run as root, and
  68. servers that you generally need and run.
  69.  
  70. Next, disable any servers that run by default and that you won't explicitly
  71. require on your network! Browse through your files, looking for suid binaries:
  72. find / \( -perm -4000 -o -perm -2000 ! -type d \) -exec ls -ldb {} \;
  73. Remove the suid flag (chmod 755 each binary) on any of the programs that
  74. don't need to be run by non-root users / scripts with root privileges.
  75. Now you need to examine your system and server configuration, most of it
  76. is in the /etc directory. Get to know your operating systems security
  77. mechanisms, and also recompile your kernel. You should have basic knowledge of
  78. every server / daemon process that you run on your machines, and check the
  79. configuration for it. Once you have done all this, you can consider to have
  80. a system with basic stability and security present. Also consider doing this
  81. on one system and copying your partitions to other systems to save yourself
  82. some work.
  83.  
  84. One more recommended thing is to block ICMP at your border router(s),
  85. to be safe from ICMP 'firewalking' and generic denial of service.
  86. To prevent 'smurf' and other flood attacks, specifically make sure your
  87. broadcast addresses do not reply to ICMP (IPs ending in .0 and .255), and
  88. (if you use IOS or something similar), make your routers detect 'flood' attacks
  89. and go into high-bandwidth or alternative-route modes if they detect a certain
  90. amount of packets in a specified amount of time. Connection-oriented routing
  91. can also be very useful. Finally, deny all other known and unknown IP protocols
  92. besides TCP, UDP and ICMP, in case you don't need them.
  93.  
  94. _______________________________________________________________________________
  95.  
  96. 2. Creating reliable audit trails
  97.  
  98. One simple precaution that everyone should take is to make sure that
  99. audit trails (in other words: logs) are present, and one instance of them
  100. cannot be altered. Compile a list of servers that you don't (!) and never
  101. will run on any of the machines on your network, and instruct your border
  102. routers that connect you with the rest of the world, to deny and log all
  103. incoming requests to those ports. Don't block port 20 unless you want to
  104. break active ftp transfers, and don't block ports above 1024 (non-privileged).
  105. You should have some instance of remote logging available, that each of
  106. your hosts uses. The easiest way is to configure syslog (see syslog.conf
  107. manpage) to log all messages to a remote loghost. A loghost is a dedicated,
  108. secured machine that runs only syslog and sshd (or not even sshd, so it is
  109. accessible only physically via console) and has enough disk space for all the
  110. logs. A good idea would also be a solution with digitally signed and/or
  111. encrypted logs to prevent manipulation and to ensure authenticity.
  112. Once you have done this, you can implement extra Intrusion Detection and
  113. firewalling services. This is recommended as extra security mechanism, but
  114. not required, if you have really secured your machines well, and a bit too
  115. much to cover it all in one article.
  116. Only this much: If you implement a firewall/IDS, then first perform step 3,
  117. install the firewall with a good rule set and perform step 3 again to audit
  118. your firewall rules and your IDS stability and logging capabilities.
  119.  
  120. _______________________________________________________________________________
  121.  
  122. 3. Penetration testing I: gathering information
  123.  
  124. Now, let us find every available service. If this step is performed before
  125. implementing a firewall, it should be performed from within the local
  126. network, to be as reliable as possible, else from behind the network border.
  127. You should use nmap [4] for port scanning, which is currently the most
  128. reliable and comprehensible way of port scanning available. Scan tcp port
  129. range 1 to 65535 and udp port range 1 to 65535 on every host, and save the
  130. results (open ports). This would look like, for example:
  131.  
  132. nmap -sT -P0 -p1-65535 -I -n 10.0.0.0/24 >> results.txt
  133. nmap -sU -P0 -p1-65535 -I -n 10.0.0.0/24 >> results.txt
  134. (This would scan hosts 10.0.0.0 to 10.0.0.255.)
  135.  
  136. Note: to audit firewall rules or IDS logging capabilities, re-run this
  137. scan with values like: -f, -sS / -sF / -sN and -g 20 / 53 / 80
  138. The results should NOT show more than normal scans, and an eventually 
  139. installed IDS should detect and log the stealth scanning tricks.
  140.  
  141. _______________________________________________________________________________
  142.  
  143. 4. Penetration testing II: evaluating information
  144.  
  145. Generally, the causes of remote network security problems
  146. can be classified into five groups:
  147.  
  148. I. Problems due to buffer overflows (ex.: exploitable imap server)
  149. II. Problems due to generally insecure programs (ex.: insecure CGI scripts)
  150. III. Problems due to insecure configuration (ex.: default samba shares)
  151. IV. Problems due to lack of or insecure passwords (ex.: SNMP daemon)
  152. V. Backdoors and trojan horses (not applicable if you went through step 1.)
  153.  
  154. Many people see a penetration check as an attempt to exploit any of these
  155. problems, if present, to gain access (hack) into a host and therefore prove
  156. that it is insecure. This is not sufficient to ensure the security in a
  157. systematical way, however, because one would omit the potential holes.
  158.  
  159. One way to start off, is using a well-designed and reliable security scanner,
  160. like NSAT [5]. I don't only recommend it because of self-promotion ;), but
  161. because it scans for a lot of vulnerabilities and does not only report them,
  162. but rather a lot of information, versions, auditing results etc. out of which
  163. one can draw its own conclusions. In contrary to many other scanners, this
  164. enables NSAT to audit services at all times with maximum efficiency, while
  165. it doesn't need to maintain a very recent vulnerabilities database. Give NSAT
  166. a try and audit the services it scans for with it. However, if you run other
  167. uncommon services, that NSAT does not scan for, or you want to be 100% safe
  168. you should afterwards scan and examine them manually as well, using
  169. telnet, netcat, browser, etc. sessions.
  170.  
  171. To actually identify all vulnerabilities, (you may have guessed it, this is
  172. the hardest part :)!), search archives of security mailing lists [8],
  173. security sites [9], and vendor sites for known security issues regarding the
  174. server, and also don't be afraid to write the author to ask if your version
  175. is vulnerable. If you find no exploits or advisories regarding your program
  176. at all, you can consider it to be secure. The better way is of course, to
  177. search updates for every server you run and install the latest versions.
  178. Retain from running anything if you don't fully understand how to configure
  179. and maintain it. In most cases, understanding a program up to the point where
  180. you know how to properly secure it, doesn't take too much work, as most
  181. GNU programs are generally well-documented and user friendly once you get
  182. to know them.
  183.  
  184. There are a few examples, where you can not audit services satisfyingly
  185. by looking at the version or performing sample sessions, namely httpd,
  186. where you have to locally examine the CGI scripts. You can use very
  187. sophisticated and flexible CGI scanners to locate vulnerable CGI's,
  188. but you can never be sure to find all by doing a remote scan. You need
  189. to locally scan your cgi-bin/ directory and scripts that may reside
  190. somewhere else in your document root. A big security risk are self-written
  191. or uncommon CGI scripts, an intruder WILL scan and find those, if he
  192. tries hard enough. Always consider every executable script on your HTTP
  193. server as relevant to security as a separate server running with the
  194. privileges of your httpd.
  195.  
  196. Another important subjects are services with password authentication.
  197. If possible, disable non-encrypted services and use kerberos-enabled
  198. mail servers, and ssh / sftp instead. It is crucial to your security to
  199. have all authentication mechanisms use strong, non-standard passwords that
  200. cannot be easily brute forced. Configuring your standard authentication
  201. not to take weak passwords at all is a good idea. If you are securing multi-
  202. user systems, you should always make secure passwords a central point in your
  203. security policy. (But designing an adequate security policy is another big,
  204. important topic besides network security.) BSD style MD5 and all DES passwords
  205. can and should be tested with John [6]; other issues with passwords exist in
  206. snmp, http auth, linuxconf, r-services, SQL and various other services.
  207.  
  208. _______________________________________________________________________________
  209.  
  210. A small collection of related articles and programs
  211.  
  212. [1] Q - stealth encryted remote shell and redirection server
  213.     http://members.tripod.com/mixtersecurity/Q-0.9.tgz
  214. [2] Brian Martin: Why your network is still vulnerable
  215.     http://www.hackernews.com/orig/whyvuln.html
  216. [3] David Curry: Improving your network by breaking into it
  217.     http://www.rootshell.com/beta/docs/improving_security_sri.ps.gz
  218. [4] Nmap by fyodor
  219.     http://www.insecure.org/nmap
  220. [5] Network security analysis tool
  221.     http://members.tripod.com/mixtersecurity/nsat-1.09.tgz
  222. [6] John the ripper by Solar Designer
  223.     http://www.false.com/security
  224. [7] Daniel V. Klein: Foiling the Cracker
  225.     http://www.rootshell.com/beta/docs/passwords_klein.ps.gz
  226. [8] Security Focus / Bugtraq Mailing List archives
  227.     http://www.securityfocus.com
  228. [9] Packet Storm Security
  229.     http://packetstorm.securify.com
  230.  
  231. _______________________________________________________________________________
  232.  
  233. Mixter <mixter@newyorkoffice.com>
  234. http://members.tripod.com/mixtersecurity
  235.